package com.example.permissionservice.service;

import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;


@Mapper
public interface RoleMapper {
    @Insert("INSERT INTO user_roles(user_id,role_id)" + "VALUES(#{userId}, '3')")
    void insert(Long userId);

    @Select("SELECT role_code FROM roles WHERE role_id = " +
            "(select role_id from user_roles where user_id=#{userId})")
    String select(Long userId);

    @Update("UPDATE user_roles SET role_id = '2' WHERE user_id = #{userId}")
    void upgrade(Long userId);

    @Update("UPDATE user_roles SET role_id = '3' WHERE user_id = #{userId}")
    void downgrade(Long userId);
}
